package edu.whu.demo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import edu.whu.demo.domain.Schedule;
import edu.whu.demo.service.IScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2022-11-24
 */
@RestController
@RequestMapping("/schedule")
public class ScheduleController {

    @Autowired
    IScheduleService scheduleService;
    /*加入日程、创建日程*/
    @PostMapping("")
    public ResponseEntity<Schedule> addSchedule(@RequestBody Schedule schedule){
        scheduleService.addSchedule(schedule);
        return null;
    }

    /*移除日程*/
    @DeleteMapping("/{id}")
    public void deleteSchedule(@PathVariable Long id){
        scheduleService.deleteSchedule(id);
    }

    /*修改日程*/
    @PutMapping("/{id}")
    public ResponseEntity<Schedule> updateScheduleUser(@PathVariable Long id,@RequestBody Schedule schedule){
       return ResponseEntity.ok(scheduleService.updateScheduleUser(id,schedule));
    }

    /*查看日程*/
    @GetMapping("")
    public IPage<Schedule> findSchedules(String searchInfo){
        return null;
    }


    /*根据id查询日程*/
    @GetMapping("/{id}")
    public ResponseEntity<Schedule> getScheduleById(@PathVariable Long id){
        return ResponseEntity.ok(scheduleService.getScheduleById(id));
    }

}

